<?php

namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Api\Helpers\ApiResponse;

class BindAccountController extends Controller
{
    use ApiResponse;
    public function  personList(Request $request)
    {
        $query = DB::table('users_bind');
        if (!$request->input('userId')) {
            return $this->failed('Incorrect userId', 403);
        }
        $query = $query->where('i_user_id',  $request->input('userId'));
        $total = $query->count();
        $list = $query->orderBy('vc_account','desc')->get();
        return response([
            'success' => true,
            'total'   => $total,
            'items'   => $list
        ]);
    }
    public function getWeChatList($openid) {
        if (!$openid) {
            return $this->failed('Incorrect $openid', 403);
        }
        $query = DB::table('users_bind');
        $query = $query->where('i_openid',  $openid);
        $total = $query->count();
        $list = $query->orderBy('vc_account','desc')->get();
        return response([
            'success' => true,
            'total'   => $total,
            'items'   => $list
        ]);
    }
}